package com.fix.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.fix.exception.BizException;
import com.fix.service.HeroService;

@Controller
public class HeroController {
	
	@Autowired
	HeroService heroService;
	
	@Autowired
	HttpServletRequest requst;
	
	@RequestMapping("/show/{page}")
	public String show(@PathVariable("page") Integer p) {
		List list = heroService.getPage(p);
		requst.setAttribute("mylist", list);
		return "show";
	} 
	
	@RequestMapping("/testnull")
	public String myerr1() throws IOException, BizException {
		String t=null;
		t.trim();
		return "show";
	} 
	
	@RequestMapping("/myerr")
	public String myerr2() throws IOException, BizException {
		int n=9;
		if(n>0) {
			throw new IOException("文件异常");
			//throw new BizException("你好，转账出错了");
		} 
		return "show";
	} 
	

}
